<?php

namespace Fize\Third\WechatWork\Qyapi;

use Fize\Third\WechatWork\QyapiAbstract;

/**
 * 成员管理
 */
class User extends QyapiAbstract
{

    /**
     * 读取成员
     * @param string $userid 成员UserID
     * @return array
     * @see https://developer.work.weixin.qq.com/document/path/90196
     */
    public function get(string $userid): array
    {
        return $this->httpGet("/user/get?access_token={$this->accessToken}&userid={$userid}");
    }

    /**
     * 成功加入企业
     * @param string $userid 成员UserID
     * @return array
     */
    public function authsucc(string $userid): array
    {
        return $this->httpGet("/user/authsucc?access_token={$this->accessToken}&userid={$userid}");
    }

    /**
     * 使用二次验证
     * @param string $userid   用户的userid
     * @param string $tfa_code 获取用户二次验证信息接口返回的tfa_code
     * @return array
     */
    public function tfaSucc(string $userid, string $tfa_code): array
    {
        $params = [
            'userid'   => $userid,
            'tfa_code' => $tfa_code
        ];
        return $this->httpPost("/user/tfa_succ?access_token={$this->accessToken}", $params);
    }
}